package com.qm.console.component.util;

import org.apache.commons.codec.binary.Base64;

import java.nio.charset.Charset;
import java.util.HashMap;
import java.util.Map;

/**
 * @Auther: jlyin
 * @Date: 2018/9/19 14:47
 * @Description:
 */
public class AuthUtil {
    public static Map<String,String> getHeadsWithAuthorition(String userName,String password){
        Map<String,String> stringMap = new HashMap<>();
        String auth = userName + ":" + password;
        byte[] encodedAuth = Base64.encodeBase64(auth.getBytes(Charset.forName("US-ASCII")));
        String authHeader = "Basic " + new String(encodedAuth);
        stringMap.put("Authorization",authHeader);
        return stringMap;
    }
}
